//
//  Character.m
//
//  Created by Mechalogical on 03/02/2010.
//  Copyright 2010 Mechalogical Labs.
//
//  This file is part of BattleGrowl.
//  
//  BattleGrowl is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
// 
//  BattleGrowl is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//  
//  You should have received a copy of the GNU General Public License
//  along with BattleGrowl.  If not, see <http://www.gnu.org/licenses/>.
// 

#import "WowCharacter.h"


@implementation WowCharacter

@dynamic name;
@dynamic realm;
@dynamic region;
@dynamic activityFeedUrl;


- (void) populateInferredFields
{
	[self populateActivityFeedUrl];
}

- (void) populateActivityFeedUrl
{	
	NSMutableString *urlString = [NSMutableString stringWithString:@"http://"];
	if([@"EU" isEqualToString:[self region]])
	{
		[urlString appendString: @"eu"];
	} 
	else if([@"US" isEqualToString:[self region]])
	{
		[urlString appendString: @"www"];
	}
	else if([@"KR" isEqualToString:[self region]])
	{
		[urlString appendString: @"kr"];
	}
	else if([@"CN" isEqualToString:[self region]])
	{
		[urlString appendString: @"cn"];
	}
	else if([@"TW" isEqualToString:[self region]])
	{
		[urlString appendString: @"tw"];
	}
	
	[urlString appendString: @".wowarmory.com"];
	[urlString appendString: @"/character-feed.atom?r="];
	[urlString appendString: [self realm]];
	[urlString appendString: @"&cn="];
	[urlString appendString: [self name]];
	[urlString appendString: @"&locale=en_US"];
	
	[self setActivityFeedUrl:urlString];	
}

@end
